<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UED设计规范演示页面</title>
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- Font Awesome -->
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        /* 自定义样式 */
        :root {
            --primary-light: rgba(59, 130, 246, 0.15);
            --primary-mid: rgba(59, 130, 246, 0.4);
            --primary-dark: rgba(59, 130, 246, 0.92);
            --primary-hover: rgba(59, 130, 246, 0.96);
            --primary-border: rgba(59, 130, 246, 0.4);
            --bg-color: #f8fafc;
            --main-color: #ffffff;
            --text-primary: #334155;
            --text-secondary: #64748b;
        }
        
        /* 背景网格层 */
        .grid-bg {
            background-image: radial-gradient(rgba(59, 130, 246, 0.05) 1px, transparent 1px);
            background-size: 20px 20px;
            background-color: var(--bg-color);
            width: 100%;
            min-height: 100vh;
        }
        
        /* 卡片样式 */
        .card {
            background-color: rgba(255, 255, 255, 0.9);
            border: 1px solid var(--primary-border);
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
            transition: all 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
        }
        
        /* 按钮样式 */
        .btn {
            padding: 0.5rem 1rem;
            border-radius: 5px;
            font-size: 0.875rem;
            font-weight: 500;
            transition: all 0.3s ease;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }
        
        .btn-primary {
            background-color: var(--primary-dark);
            color: white;
            border: none;
        }
        
        .btn-primary:hover {
            background-color: var(--primary-hover);
        }
        
        /* 文本平衡 */
        .text-balance {
            text-wrap: balance;
        }
        
        /* 激活状态指示 */
        .active-item {
            position: relative;
            padding-left: 1rem;
        }
        
        .active-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0.25rem;
            bottom: 0.25rem;
            width: 3px;
            background-color: var(--primary-dark);
            border-radius: 3px;
        }
        
        /* 自定义动画 */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .fade-in {
            animation: fadeIn 0.5s ease-out forwards;
        }
        
        @keyframes pulse {
            0%, 100% {
                opacity: 1;
            }
            50% {
                opacity: 0.7;
            }
        }
        
        .pulse {
            animation: pulse 2s infinite;
        }
        
        /* 通知点脉冲动画 */
        @keyframes notificationPulse {
            0% {
                transform: scale(1);
                opacity: 1;
            }
            50% {
                transform: scale(1.2);
                opacity: 0.8;
            }
            100% {
                transform: scale(1);
                opacity: 1;
            }
        }
        
        .notification-pulse {
            animation: notificationPulse 2s infinite;
        }
        
        @keyframes float {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-4px);
            }
        }
        
        .float-animation {
            animation: float 3s ease-in-out infinite;
        }
        
        /* 悬浮效果 */
        .hover-lift {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        
        .hover-lift:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
        }
        
        /* 数据更新动画 */
        @keyframes dataUpdate {
            0% {
                background-color: rgba(59, 130, 246, 0.1);
            }
            50% {
                background-color: rgba(59, 130, 246, 0.2);
            }
            100% {
                background-color: transparent;
            }
        }
        
        .data-updated {
            animation: dataUpdate 1s ease-out;
        }
        
        /* 渐变边框效果 */
        .gradient-border {
            position: relative;
            border-radius: 12px;
            z-index: 0;
        }
        
        .gradient-border::before {
            content: "";
            position: absolute;
            inset: -2px;
            background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
            border-radius: 12px;
            z-index: -1;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .gradient-border:hover::before {
            opacity: 1;
        }
        
        .gradient-border > * {
            position: relative;
            z-index: 1;
        }
        
        /* 加载动画 */
        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }
        
        .loader {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 2px solid rgba(59, 130, 246, 0.3);
            border-radius: 50%;
            border-top-color: var(--primary-dark);
            animation: spin 0.8s ease-in-out infinite;
        }
        
        /* 通知点 */
        .notification-dot {
            position: absolute;
            top: -2px;
            right: -2px;
            width: 8px;
            height: 8px;
            background-color: #ef4444;
            border-radius: 50%;
            animation: pulse 1.5s infinite;
        }
        
        /* 玻璃态效果 */
        .glass-effect {
            background: rgba(255, 255, 255, 0.7);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
        }
        
        /* 搜索框样式 */
        .search-input {
            background-color: rgba(255, 255, 255, 0.8);
            border: 1px solid var(--primary-border);
            border-radius: 5px;
            padding: 0.5rem 2rem;
            font-size: 0.875rem;
            width: 100%;
            transition: border-color 0.3s ease;
        }
        
        .search-input:focus {
            outline: none;
            border-color: var(--primary-dark);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
        }
        
        .search-icon {
            position: absolute;
            left: 0.75rem;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-secondary);
        }
        
        .search-input-wrapper {
            position: relative;
            max-width: 320px;
        }
        
        /* 搜索筛选容器 */
        .search-filter-container {
            display: flex;
            flex-wrap: wrap;
            gap: 2rem;
            align-items: flex-end;
            margin-bottom: 2rem;
        }
        
        /* 数据卡片样式 */
        .data-card {
            position: relative;
        }
        
        .data-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }
        
        .data-card-title {
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-primary);
        }
        
        .data-card-content {
            margin-bottom: 1rem;
        }
        
        .data-value {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 0.25rem;
        }
        
        .data-trend {
            font-size: 0.75rem;
            font-weight: 500;
        }
        
        .data-trend.positive {
            color: #10b981;
        }
        
        .data-trend.negative {
            color: #ef4444;
        }
        
        .data-trend-text {
            color: var(--text-secondary);
            font-weight: 400;
        }
        
        .data-card-footer {
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }
        
        .progress-bar {
            height: 4px;
            background-color: #f1f5f9;
            border-radius: 2px;
            overflow: hidden;
        }
        
        .progress {
            height: 100%;
            background-color: var(--primary-dark);
            border-radius: 2px;
            transition: width 0.5s ease;
        }
        
        .progress-text {
            font-size: 0.75rem;
            color: var(--text-secondary);
        }
        
        /* 功能卡片样式 */
        .feature-card {
            display: flex;
            flex-direction: column;
            text-decoration: none;
            height: 100%;
        }
        
        .feature-icon {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            margin-bottom: 0.75rem;
        }
        
        .feature-title {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 0.5rem;
        }
        
        .feature-description {
            font-size: 0.875rem;
            color: var(--text-secondary);
            margin-bottom: 1rem;
            line-height: 1.5;
            flex: 1;
        }
        
        .feature-action {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.875rem;
            font-weight: 500;
            transition: color 0.3s ease;
        }
        
        .feature-card:hover .feature-action {
            opacity: 0.8;
        }
        
        /* 网格选择器样式 */
        .grid-selector {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            gap: 1rem;
        }
        
        .grid-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 1rem;
            border: 1px solid var(--primary-border);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            background-color: white;
        }
        
        .grid-item:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }
        
        .grid-item.selected {
            border-color: var(--primary-dark);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
        }
        
        .grid-color {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-bottom: 0.5rem;
        }
        
        /* 区域样式 */
        .section {
            margin-bottom: 3rem;
        }
        
        .section-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 1.5rem;
        }
        
        /* 卡片网格布局 */
        .card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1.5rem;
        }
        
        /* 按钮网格布局 */
        .button-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 1rem;
        }
        
        /* 功能网格布局 */
        .feature-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1.5rem;
        }
        
        /* 背景色类 */
        .bg-blue-10 {
            background-color: rgba(59, 130, 246, 0.1);
        }
        
        .bg-green-10 {
            background-color: rgba(16, 185, 129, 0.1);
        }
        
        .bg-purple-10 {
            background-color: rgba(139, 92, 246, 0.1);
        }
        
        .bg-orange-10 {
            background-color: rgba(245, 158, 11, 0.1);
        }
        
        .bg-red-50 {
            background-color: #fee2e2;
        }
        
        .bg-blue-50 {
            background-color: #dbeafe;
        }
        
        .bg-green-50 {
            background-color: #d1fae5;
        }
        
        .bg-yellow-50 {
            background-color: #fef3c7;
        }
        
        .bg-purple-50 {
            background-color: #e0e7ff;
        }
        
        .bg-pink-50 {
            background-color: #fce7f3;
        }
    </style>
</head>
<body>
    <!-- 背景网格层 -->
    <article class="grid-bg min-h-screen w-full">
        
        <!-- 主要内容层 -->
        <section id="main-content" class="max-w-7xl mx-auto px-4 py-6 md:py-8">
            <!-- 页面标题区 -->
            <header class="mb-6 pb-4 border-b border-[rgba(99,116,139,0.2)]">
                <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
                    <div>
                        <h1 class="text-[clamp(1.5rem,3vw,2rem)] font-bold text-[#334155]">UED设计规范演示页面</h1>
                        <p class="text-[#64748b] mt-2">展示符合现代设计理念的UI组件和交互效果</p>
                    </div>
                    <div class="flex gap-3">
                        <button class="btn btn-primary">
                            <i class="fa fa-plus"></i>
                            <span>创建新组件</span>
                        </button>
                        <button class="btn bg-white border border-[rgba(59,130,246,0.4)] text-[#334155]">
                            <i class="fa fa-cog"></i>
                            <span>设置</span>
                        </button>
                    </div>
                </div>
            </header>
            
            <!-- 主内容区 -->
    <main id="content-main" class="space-y-8">
        <!-- 搜索筛选区域 -->
        <div class="search-filter-container">
            <div class="search-wrapper max-w-md mb-6">
                <i class="fa fa-search search-icon"></i>
                <input type="text" placeholder="搜索组件..." class="search-input w-full">
            </div>
            <div class="flex flex-wrap gap-2 mb-6">
                <button class="active-item px-4 py-2 bg-[rgba(59,130,246,0.15)] text-[#334155] rounded-lg">
                    所有组件
                </button>
                <button class="px-4 py-2 bg-white text-[#64748b] rounded-lg hover:bg-gray-50">
                    数据展示
                </button>
                <button class="px-4 py-2 bg-white text-[#64748b] rounded-lg hover:bg-gray-50">
                    表单控件
                </button>
                <button class="px-4 py-2 bg-white text-[#64748b] rounded-lg hover:bg-gray-50">
                    导航组件
                </button>
                <button class="px-4 py-2 bg-white text-[#64748b] rounded-lg hover:bg-gray-50">
                    交互组件
                </button>
            </div>
        </div>
        
        <!-- 数据卡片示例 -->
        <div class="section mb-8">
            <h2 class="section-title text-xl font-semibold text-[#334155] mb-4">数据卡片组件</h2>
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                <!-- 数据卡片 1 -->
                <div class="data-card card p-4 hover-lift gradient-border">
                    <div class="data-card-header flex justify-between items-center mb-3">
                        <h3 class="data-card-title font-medium text-[#334155]">系统用户</h3>
                        <span class="notification-dot pulse-animation"></span>
                    </div>
                    <div class="data-card-content mb-4">
                        <div class="data-value text-2xl font-bold text-[#334155]">1,254</div>
                        <div class="data-trend positive text-green-500 text-sm">+12% <span class="data-trend-text">较上月</span></div>
                    </div>
                    <div class="data-card-footer">
                        <div class="progress-bar h-1 bg-gray-100 rounded-full mb-1">
                            <div class="progress h-full bg-[var(--primary-dark)] rounded-full" style="width: 75%"></div>
                        </div>
                        <div class="progress-text text-xs text-[#64748b]">完成度 75%</div>
                    </div>
                </div>
                
                <!-- 数据卡片 2 -->
                <div class="data-card card p-4">
                    <div class="data-card-header flex justify-between items-center mb-3">
                        <h3 class="data-card-title font-medium text-[#334155]">活跃会话</h3>
                    </div>
                    <div class="data-card-content mb-4">
                        <div class="data-value text-2xl font-bold text-[#334155]">387</div>
                        <div class="data-trend negative text-red-500 text-sm">-3% <span class="data-trend-text">较昨日</span></div>
                    </div>
                    <div class="data-card-footer">
                        <div class="progress-bar h-1 bg-gray-100 rounded-full mb-1">
                            <div class="progress h-full bg-[var(--primary-dark)] rounded-full" style="width: 45%"></div>
                        </div>
                        <div class="progress-text text-xs text-[#64748b]">完成度 45%</div>
                    </div>
                </div>
                
                <!-- 数据卡片 3 -->
                <div class="data-card card p-4">
                    <div class="data-card-header flex justify-between items-center mb-3">
                        <h3 class="data-card-title font-medium text-[#334155]">存储空间</h3>
                    </div>
                    <div class="data-card-content mb-4">
                        <div class="data-value text-2xl font-bold text-[#334155]">23.4 GB</div>
                        <div class="data-trend positive text-green-500 text-sm">+5.2% <span class="data-trend-text">较上周</span></div>
                    </div>
                    <div class="data-card-footer">
                        <div class="progress-bar h-1 bg-gray-100 rounded-full mb-1">
                            <div class="progress h-full bg-[var(--primary-dark)] rounded-full" style="width: 62%"></div>
                        </div>
                        <div class="progress-text text-xs text-[#64748b]">完成度 62%</div>
                    </div>
                </div>
                
                <!-- 数据卡片 4 -->
                <div class="data-card card p-4">
                    <div class="data-card-header flex justify-between items-center mb-3">
                        <h3 class="data-card-title font-medium text-[#334155]">响应时间</h3>
                    </div>
                    <div class="data-card-content mb-4">
                        <div class="data-value text-2xl font-bold text-[#334155]">236 ms</div>
                        <div class="data-trend positive text-green-500 text-sm">-15% <span class="data-trend-text">较优化前</span></div>
                    </div>
                    <div class="data-card-footer">
                        <div class="progress-bar h-1 bg-gray-100 rounded-full mb-1">
                            <div class="progress h-full bg-[var(--primary-dark)] rounded-full" style="width: 88%"></div>
                        </div>
                        <div class="progress-text text-xs text-[#64748b]">完成度 88%</div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 按钮组件示例 -->
        <div class="section mb-8">
            <h2 class="section-title text-xl font-semibold text-[#334155] mb-4">按钮组件</h2>
            <div class="button-grid flex flex-wrap gap-3">
                <button class="btn btn-primary">主要按钮</button>
                <button class="btn bg-white border border-gray-200 text-[#334155]">次要按钮</button>
                <button class="btn bg-white border border-[var(--primary-border)] text-[var(--primary-dark)]">轮廓按钮</button>
                <button class="btn bg-transparent text-[#334155] hover:bg-gray-50">文本按钮</button>
                <button class="btn btn-primary opacity-50" disabled>禁用按钮</button>
                <button class="btn btn-primary p-2">
                    <i class="fa fa-plus"></i>
                </button>
            </div>
        </div>
        
        <!-- 功能卡片示例 -->
        <div class="section mb-8">
            <h2 class="section-title text-xl font-semibold text-[#334155] mb-4">功能卡片</h2>
            <div class="feature-grid grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                <!-- 功能卡片 1 -->
                <a href="#" class="feature-card card p-5 hover-lift">
                    <div class="feature-icon bg-blue-50 p-3 rounded-lg inline-flex mb-3">
                        <i class="fa fa-bar-chart text-blue-500 text-xl"></i>
                    </div>
                    <h3 class="feature-title font-semibold text-[#334155] mb-2">数据统计</h3>
                    <p class="feature-description text-sm text-[#64748b] mb-4">实时监控系统各项指标，提供详细的数据统计分析</p>
                    <div class="feature-action flex items-center text-[var(--primary-dark)] text-sm">
                        <span>查看详情</span>
                        <i class="fa fa-arrow-right ml-2"></i>
                    </div>
                </a>
                
                <!-- 功能卡片 2 -->
                <a href="#" class="feature-card card p-5">
                    <div class="feature-icon bg-green-50 p-3 rounded-lg inline-flex mb-3">
                        <i class="fa fa-tasks text-green-500 text-xl"></i>
                    </div>
                    <h3 class="feature-title font-semibold text-[#334155] mb-2">任务管理</h3>
                    <p class="feature-description text-sm text-[#64748b] mb-4">高效管理日常工作任务，设置优先级和截止日期</p>
                    <div class="feature-action flex items-center text-green-500 text-sm">
                        <span>查看详情</span>
                        <i class="fa fa-arrow-right ml-2"></i>
                    </div>
                </a>
                
                <!-- 功能卡片 3 -->
                <a href="#" class="feature-card card p-5">
                    <div class="feature-icon bg-purple-50 p-3 rounded-lg inline-flex mb-3">
                        <i class="fa fa-file-text text-purple-500 text-xl"></i>
                    </div>
                    <h3 class="feature-title font-semibold text-[#334155] mb-2">报告生成</h3>
                    <p class="feature-description text-sm text-[#64748b] mb-4">自动生成各类数据报告，支持多种格式导出和分享</p>
                    <div class="feature-action flex items-center text-purple-500 text-sm">
                        <span>查看详情</span>
                        <i class="fa fa-arrow-right ml-2"></i>
                    </div>
                </a>
                
                <!-- 功能卡片 4 -->
                <a href="#" class="feature-card card p-5">
                    <div class="feature-icon bg-orange-50 p-3 rounded-lg inline-flex mb-3">
                        <i class="fa fa-eye text-orange-500 text-xl"></i>
                    </div>
                    <h3 class="feature-title font-semibold text-[#334155] mb-2">系统监控</h3>
                    <p class="feature-description text-sm text-[#64748b] mb-4">实时监控系统运行状态，及时发现并解决潜在问题</p>
                    <div class="feature-action flex items-center text-orange-500 text-sm">
                        <span>查看详情</span>
                        <i class="fa fa-arrow-right ml-2"></i>
                    </div>
                </a>
            </div>
        </div>
        
        <!-- 网格排列示例 -->
        <div class="section mb-8">
            <h2 class="section-title text-xl font-semibold text-[#334155] mb-4">网格选择器</h2>
            <div class="grid-selector grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-3">
                <div class="grid-item p-3 border border-[var(--primary-dark)] rounded-lg flex flex-col items-center">
                    <div class="grid-color bg-red-50 w-10 h-10 rounded-full mb-2"></div>
                    <span class="text-sm text-[#334155]">红色</span>
                </div>
                <div class="grid-item p-3 border border-gray-200 rounded-lg flex flex-col items-center">
                    <div class="grid-color bg-blue-50 w-10 h-10 rounded-full mb-2"></div>
                    <span class="text-sm text-[#334155]">蓝色</span>
                </div>
                <div class="grid-item p-3 border border-gray-200 rounded-lg flex flex-col items-center">
                    <div class="grid-color bg-green-50 w-10 h-10 rounded-full mb-2"></div>
                    <span class="text-sm text-[#334155]">绿色</span>
                </div>
                <div class="grid-item p-3 border border-gray-200 rounded-lg flex flex-col items-center">
                    <div class="grid-color bg-yellow-50 w-10 h-10 rounded-full mb-2"></div>
                    <span class="text-sm text-[#334155]">黄色</span>
                </div>
                <div class="grid-item p-3 border border-gray-200 rounded-lg flex flex-col items-center">
                    <div class="grid-color bg-purple-50 w-10 h-10 rounded-full mb-2"></div>
                    <span class="text-sm text-[#334155]">紫色</span>
                </div>
                <div class="grid-item p-3 border border-gray-200 rounded-lg flex flex-col items-center">
                    <div class="grid-color bg-pink-50 w-10 h-10 rounded-full mb-2"></div>
                    <span class="text-sm text-[#334155]">粉色</span>
                </div>
            </div>
        </div>
    </main>
        </section>
    </article>
    <script type="module">
        // 初始化脚本
        function initApp() {
            console.log('初始化应用');
            // 确保DOM完全加载
            if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', function() {
                    updateHeight();
                    setupEventListeners();
                    initLocalStorageData();
                    loadDataFromStorage();
                });
            } else {
                updateHeight();
                setupEventListeners();
                initLocalStorageData();
                loadDataFromStorage();
            }
        }
        
        // 设置事件监听器
        function setupEventListeners() {
            // 监听窗口大小变化
            window.addEventListener('resize', debounce(updateHeight, 200));
            // 监听设备方向变化
            window.addEventListener('orientationchange', updateHeight);
            
            // 为网格选择器添加点击事件
            var gridItems = document.querySelectorAll('.grid-item');
            gridItems.forEach(function(item) {
                item.addEventListener('click', function() {
                    selectGridItem(this);
                });
            });
            
            // 为按钮添加点击事件，模拟数据更新
            var actionButtons = document.querySelectorAll('.btn-primary, .btn-secondary');
            actionButtons.forEach(function(button) {
                button.addEventListener('click', function() {
                    simulateDataUpdate();
                });
            });
        }
        
        // 防抖函数
        function debounce(func, wait) {
            var timeout;
            return function() {
                var context = this;
                var args = arguments;
                clearTimeout(timeout);
                timeout = setTimeout(function() {
                    func.apply(context, args);
                }, wait);
            };
        }
        
        // 动态计算高度
        function updateHeight() {
            try {
                var mainContent = document.getElementById('content-main');
                if (mainContent) {
                    var windowHeight = window.innerHeight;
                    var bodyRect = document.body.getBoundingClientRect();
                    var header = document.querySelector('header');
                    var headerHeight = 0;
                    
                    if (header) {
                        var headerRect = header.getBoundingClientRect();
                        headerHeight = headerRect.height + headerRect.top;
                    }
                    
                    // 计算内容区域的最小高度，考虑页面顶部和底部的间距
                    var contentMinHeight = windowHeight - headerHeight - 100; // 100px 为底部边距
                    
                    // 设置最小高度，确保内容区域至少占满可视区域剩余空间
                    if (contentMinHeight > 0) {
                        mainContent.style.minHeight = contentMinHeight + 'px';
                    }
                }
            } catch (error) {
                console.error('动态高度计算失败:', error);
                // 降级方案
                try {
                    var mainContent = document.getElementById('content-main');
                    if (mainContent) {
                        mainContent.style.minHeight = '800px';
                    }
                } catch (fallbackError) {
                    console.error('降级方案执行失败:', fallbackError);
                }
            }
        }
        
        // localStorage相关功能
        
        // 获取默认卡片数据
        function getDefaultCardData() {
            return {
                systemUsers: {
                    value: 1258,
                    trend: 12.5,
                    positive: true,
                    progress: 78
                },
                activeSessions: {
                    value: 48,
                    trend: 5.2,
                    positive: true,
                    progress: 65
                },
                apiCalls: {
                    value: 18453,
                    trend: -3.8,
                    positive: false,
                    progress: 92
                },
                dataStorage: {
                    value: 4256,
                    trend: 8.3,
                    positive: true,
                    progress: 45
                }
            };
        }
        
        // 初始化localStorage数据
        function initLocalStorageData() {
            try {
                // 初始化或修复数据卡片数据
                var cardData;
                var cardDataStr = localStorage.getItem('demo_cardData');
                
                if (cardDataStr) {
                    try {
                        cardData = JSON.parse(cardDataStr);
                        // 验证数据完整性，修复缺失的字段
                        var defaultData = getDefaultCardData();
                        for (var key in defaultData) {
                            if (!cardData[key]) {
                                cardData[key] = defaultData[key];
                                console.warn('修复缺失的卡片数据:', key);
                            }
                        }
                    } catch (parseError) {
                        console.error('解析卡片数据失败，使用默认数据:', parseError);
                        cardData = getDefaultCardData();
                    }
                } else {
                    cardData = getDefaultCardData();
                }
                
                // 确保数据持久化
                localStorage.setItem('demo_cardData', JSON.stringify(cardData));
                
                // 检查网格选择器数据
                var selectedColorExists = localStorage.getItem('demo_selectedColor');
                if (!selectedColorExists) {
                    localStorage.setItem('demo_selectedColor', 'blue');
                }
                
                // 检查UI设置数据
                var uiSettingsExists = localStorage.getItem('demo_uiSettings');
                if (!uiSettingsExists) {
                    var defaultUiSettings = {
                        theme: 'light',
                        animationEnabled: true,
                        notifications: true
                    };
                    localStorage.setItem('demo_uiSettings', JSON.stringify(defaultUiSettings));
                }
            } catch (error) {
                console.error('初始化localStorage数据失败:', error);
            }
        }
        
        // 从localStorage加载数据
        function loadDataFromStorage() {
            try {
                // 加载卡片数据
                var cardDataStr = localStorage.getItem('demo_cardData');
                if (cardDataStr) {
                    try {
                        var cardData = JSON.parse(cardDataStr);
                        updateDataCards(cardData);
                    } catch (parseError) {
                        console.error('解析卡片数据失败:', parseError);
                        // 重置数据
                        initLocalStorageData();
                    }
                }
                
                // 加载选中的颜色
                var selectedColor = localStorage.getItem('demo_selectedColor');
                if (selectedColor) {
                    highlightSelectedColor(selectedColor);
                }
                
                // 加载UI设置
                var uiSettingsStr = localStorage.getItem('demo_uiSettings');
                if (uiSettingsStr) {
                    try {
                        var uiSettings = JSON.parse(uiSettingsStr);
                        applyUiSettings(uiSettings);
                    } catch (parseError) {
                        console.error('解析UI设置失败:', parseError);
                    }
                }
            } catch (error) {
                console.error('从localStorage加载数据失败:', error);
            }
        }
        
        // 更新数据卡片显示
        function updateDataCards(data) {
            // 为数据卡片添加ID
            var dataCards = document.querySelectorAll('.data-card');
            var cardKeys = ['systemUsers', 'activeSessions', 'apiCalls', 'dataStorage'];
            
            dataCards.forEach(function(card, index) {
                if (cardKeys[index] && data[cardKeys[index]]) {
                    updateCard(card, data[cardKeys[index]]);
                } else {
                    // 确保即使数据不存在也显示默认值
                    console.warn('Card data missing for key:', cardKeys[index]);
                    updateCard(card, {
                        value: 0,
                        trend: 0,
                        positive: true,
                        progress: 0
                    });
                }
            });
        }
        
        // 更新单个卡片
        function updateCard(card, cardData) {
            // 确保cardData存在并有默认值
            cardData = cardData || {};
            
            // 更新数值
            var valueElement = card.querySelector('.data-value');
            if (valueElement) {
                var value = typeof cardData.value === 'number' ? cardData.value : 0;
                valueElement.textContent = formatNumber(value);
            }
            
            // 更新趋势
            var trendElement = card.querySelector('.data-trend');
            if (trendElement) {
                var positive = cardData.positive !== undefined ? cardData.positive : true;
                var trendValue = typeof cardData.trend === 'number' ? cardData.trend : 0;
                var trendSign = positive ? '+' : '-';
                var trendContent = trendSign + Math.abs(trendValue).toFixed(1) + '%';
                
                var trendText = trendElement.querySelector('.data-trend-text');
                if (trendText) {
                    var originalText = trendText.textContent || '';
                    trendText.parentNode.textContent = trendContent + ' ' + originalText;
                } else {
                    trendElement.textContent = trendContent;
                }
                
                trendElement.className = 'data-trend ' + (positive ? 'positive' : 'negative');
            }
            
            // 更新进度条
            var progressElement = card.querySelector('.progress');
            if (progressElement) {
                var progress = typeof cardData.progress === 'number' ? cardData.progress : 0;
                progressElement.style.width = Math.max(0, Math.min(100, progress)) + '%';
            }
            
            // 更新进度文本
            var progressTextElement = card.querySelector('.progress-text');
            if (progressTextElement) {
                var progressValue = typeof cardData.progress === 'number' ? cardData.progress : 0;
                progressTextElement.textContent = '完成度 ' + Math.max(0, Math.min(100, progressValue)) + '%';
            }
        }
        
        // 格式化数字
        function formatNumber(num) {
            if (typeof num === 'number') {
                return num.toLocaleString();
            } else if (num === undefined || num === null || num === '') {
                return '0';
            }
            return String(num);
        }
        
        // 高亮选中的颜色
        function highlightSelectedColor(color) {
            var gridItems = document.querySelectorAll('.grid-item');
            gridItems.forEach(function(item) {
                // 通过文本内容匹配颜色
                var itemText = item.textContent.trim().toLowerCase();
                if (itemText.includes(color)) {
                    item.classList.add('selected');
                    item.classList.remove('border-gray-200');
                    item.classList.add('border-[var(--primary-dark)]');
                } else {
                    item.classList.remove('selected');
                    item.classList.add('border-gray-200');
                    item.classList.remove('border-[var(--primary-dark)]');
                }
            });
        }
        
        // 选择网格项
        function selectGridItem(item) {
            try {
                // 获取颜色文本
                var colorText = item.textContent.trim().toLowerCase();
                localStorage.setItem('demo_selectedColor', colorText);
                
                // 更新所有项的样式
                var gridItems = document.querySelectorAll('.grid-item');
                gridItems.forEach(function(gridItem) {
                    gridItem.classList.remove('selected');
                    gridItem.classList.add('border-gray-200');
                    gridItem.classList.remove('border-[var(--primary-dark)]');
                });
                
                // 添加选中样式
                item.classList.add('selected');
                item.classList.remove('border-gray-200');
                item.classList.add('border-[var(--primary-dark)]');
            } catch (error) {
                console.error('保存选中颜色失败:', error);
            }
        }
        
        // 应用UI设置
        function applyUiSettings(settings) {
            // 可以根据settings应用不同的UI配置
            console.log('应用UI设置:', settings);
        }
        
        // 模拟数据更新
        function simulateDataUpdate() {
            // 显示加载状态
            showLoadingState(true);
            
            // 延迟1-3秒更新数据
            var delay = Math.floor(Math.random() * 2000) + 1000; // 1-3秒
            
            setTimeout(function() {
                try {
                    // 获取当前数据
                    var cardDataStr = localStorage.getItem('demo_cardData');
                    var cardData = cardDataStr ? JSON.parse(cardDataStr) : {
                        systemUsers: {
                            value: 1254,
                            trend: 12,
                            positive: true,
                            progress: 75
                        },
                        activeSessions: {
                            value: 387,
                            trend: 3,
                            positive: false,
                            progress: 45
                        },
                        storageSpace: {
                            value: 23.4,
                            trend: 5.2,
                            positive: true,
                            progress: 62
                        },
                        responseTime: {
                            value: 236,
                            trend: 15,
                            positive: true,
                            progress: 88
                        }
                    };
                    
                    // 更新数据
                    Object.keys(cardData).forEach(function(key) {
                        var data = cardData[key];
                        // 随机更新数值
                        var valueChange = Math.floor(Math.random() * 100) - 20; // -20 到 79
                        data.value = Math.max(0, data.value + valueChange);
                        
                        // 随机更新趋势
                        data.trend = (Math.random() * 20 - 5).toFixed(1); // -5.0 到 14.9
                        data.positive = parseFloat(data.trend) >= 0;
                        
                        // 随机更新进度
                        data.progress = Math.min(100, Math.max(0, data.progress + (Math.floor(Math.random() * 10) - 5)));
                    });
                    
                    // 保存更新后的数据
                    localStorage.setItem('demo_cardData', JSON.stringify(cardData));
                    
                    // 更新UI显示
                        updateDataCards(cardData);
                        
                        // 为卡片添加更新动画
                        var cards = document.querySelectorAll('.data-card');
                        cards.forEach(function(card) {
                            animateDataUpdate(card);
                        });
                    
                } catch (error) {
                    console.error('模拟数据更新失败:', error);
                } finally {
                    // 隐藏加载状态
                    showLoadingState(false);
                }
            }, delay);
        }
        
        // 显示/隐藏加载状态
        function showLoadingState(show) {
            var cards = document.querySelectorAll('.data-card');
            
            cards.forEach(function(card) {
                // 获取卡片中的加载指示器，如果不存在则创建
                var loader = card.querySelector('.card-loader');
                if (!loader && show) {
                    loader = document.createElement('div');
                    loader.className = 'card-loader absolute inset-0 flex items-center justify-center bg-white bg-opacity-80 z-10 rounded-12';
                    var spinner = document.createElement('div');
                    spinner.className = 'loader';
                    loader.appendChild(spinner);
                    loader.style.display = 'none';
                    card.appendChild(loader);
                }
                
                if (loader) {
                    loader.style.display = show ? 'flex' : 'none';
                }
                
                // 添加/移除加载动画类
                if (show) {
                    card.classList.add('loading');
                } else {
                    card.classList.remove('loading');
                }
            });
        }
        
        // 添加数据更新动画
        function animateDataUpdate(element) {
            if (element) {
                element.classList.add('data-updated');
                setTimeout(function() {
                    element.classList.remove('data-updated');
                }, 1000);
            }
        }
        
        // 初始化应用
        initApp();
    </script>
</body>
</html>